package conf

type Env string

const (
	EnvDev  Env = "dev"  // 开发环境
	EnvProd Env = "prod" // 正式环境
	EnvTest Env = "test" // 测试环境
)

type Directories struct {
	Static string `mapstructure:"static" json:"static" yaml:"static"`
	Doc    string `mapstructure:"doc" json:"doc" yaml:"doc"`
}

type AppConfig struct {
	// Name        string       `mapstructure:"name" json:"name" yaml:"name"`
	Env         Env          `mapstructure:"env" json:"env" yaml:"env"`
	Host        string       `mapstructure:"host" json:"host" yaml:"host"`
	Port        int          `mapstructure:"port" json:"port" yaml:"port"`
	Directories *Directories `mapstructure:"directories" json:"directories" yaml:"directories"`

	// System AppConfig    `mapstructure:"system" json:"system" yaml:"system"`
	DB    DbConfig     `mapstructure:"db" json:"db" yaml:"db"`
	Zap   ZapConfig    `mapstructure:"zap" json:"zap" yaml:"zap"`
	Cors  *CorsConfig  `mapstructure:"cors" json:"cors" yaml:"cors"`
	JWT   *JwtConfig   `mapstructure:"jwt" json:"jwt" yaml:"jwt"`
	Redis *RedisConfig `mapstructure:"redis" json:"redis" yaml:"redis"`
}

func (c *AppConfig) JwtEnabled() bool {
	return c.JWT != nil && c.JWT.Enable
}

func (c *AppConfig) CorsEnabled() bool {
	return c.Cors != nil && c.Cors.Enable
}
